package com.hyts.dbmeta.config;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * Created by Administrator on 2019/6/26.
 * Package:com.hyts.dbmeta.config
 */
@AllArgsConstructor
public enum DbTypeConfig {


    UNKNOWN("unknown"),

    /***********MYSQL苏巨亏**************/

    MYSQL_OLD("mysql"),

    MYSQL_NEW("mysql_new");


    @Getter
    @Setter
    private String code;

    /**
     * @param code
     * @return
     */
    public static DbTypeConfig validate(String code){
        //判断是否进行数据库类型控制
        DbTypeConfig[] elements = DbTypeConfig.values();
        for(DbTypeConfig dbTypeConfig:elements){
            if(dbTypeConfig.getCode().equals(code.toLowerCase())){
                return dbTypeConfig;
            }
        }
        return DbTypeConfig.UNKNOWN;
    }
}
